package com.shunhe.storage.ui.order_receive;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.ruitu.arad.base.BaseActivity;
import com.shunhe.storage.R;

// 入库接单
public class ReceiveOrderInActivity extends BaseActivity {
    private XTabLayout tab_2;// tab_2
    private ViewPager vp_order;//

    private VpAdapter adapter;
    public static final String[] HOME_MODELS = {"待接单", "待接车", "已处理"};

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_receive_order_in1;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tab_2 = findViewById(R.id.tab_2);
        vp_order = findViewById(R.id.vp_order);

        setHeadTitle("入库接单");

        for (int i = 0; i < 3; i++) {
            tab_2.addTab(tab_2.newTab().setText(HOME_MODELS[i]), i);
        }

        adapter = new VpAdapter(getSupportFragmentManager());
        vp_order.setAdapter(adapter);
        tab_2.setupWithViewPager(vp_order);

    }

    private class VpAdapter extends FragmentPagerAdapter {

        public VpAdapter(@NonNull FragmentManager fm) {
            super(fm);
        }

        @NonNull
        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return ReceiveOrderIn1Fragment.newInstance("0");
            } else if (position == 1) {
                return ReceiveOrderIn1Fragment.newInstance("1");
            } else if (position == 2) {
                return ReceiveOrderIn1Fragment.newInstance("2");
            }
            return ReceiveOrderIn1Fragment.newInstance("0");
        }

        @Override
        public int getCount() {
            return 3;
        }

        @Nullable
        @Override
        public CharSequence getPageTitle(int position) {
            return HOME_MODELS[position];
        }
    }
}